feat: support subgroup aesthetic in geom_polygon for holes#305
feat: support subgroup aesthetic in geom_polygon for holes#305AviraL0013 wants to merge 5 commits intoanimint:masterfrom
Conversation
|
this is encouraging thanks. |
|
Thanks for the feedback @tdhock! I investigated using Finding: The D3 v3 build bundled with animint2 ( To use the
The implementation would then:
Which approach do you prefer — upgrading the full D3 v3 bundle, or extracting just the geo path functions? Edit: On rechecking, |
|
thanks. please try whatever approach is simpler and easier to review? |
|
So Sorry for the confusion earlier @tdhock! I had incorrectly concluded that So the simplest approach is to use |
- Replace manual SVG subpath concatenation with d3.geo.path() - Construct GeoJSON Polygon from subgroup coordinate rings - Keep fill-rule: evenodd as safety net for winding order - Consolidate tests for easier review (215 -> 131 lines)
D3 Geo Path Update NotesUpdated to use Changes
|

Problem
working on #252
When using
isoband::isobands()to generate contour data for shapes with holes (like a donut/ring), animint2 was rendering two separate filled polygons instead of one polygon with a transparent hole. This made it impossible to correctly visualize Hi-C genomic cluster contours and similar real-world data.Before (bug):

The root cause was a two-layer problem:
subgroupaesthetic (added in ggplot2 3.2.0) was completely absent fromGeomPolygon— not indefault_aes, not detected by the compilerfill-rulelogic existed — SVG requiresfill-rule: evenoddto render polygon holes correctlySolution
R/geom-polygon.rAdded
subgroup = NULLtodefault_aessoGeomPolygonrecognizes the aesthetic.R/geom-.rIn
export_animint, added detection ofsubgroupaesthetic on polygon geoms and setsg$data_has_subgroup <- TRUE. This flag gets serialized intoplot.jsonand read by the browser renderer.inst/htmljs/animint.jsModified
eActionsfor grouped geoms to:g_info.data_has_subgroup"subgroup"column usingd3.nest()"Z"fill-rule: evenodd— standard SVG technique for holesKey finding:
ggplot_buildrenames data columns to the aesthetic name, so the TSV column is always"subgroup"regardless of the original variable name in the data.After (fix):

Reproducer
@tdhock Could you please take a look
TODO
clickID/mouseMove